﻿/*----------------------------------------------------------------
    Copyright (C) 2017 Senparc
    
    文件名：MessageHandler.Event.cs
    文件功能描述：微信请求的集中处理方法：Message相关
    
    
    创建标识：Senparc - 20150924
    
----------------------------------------------------------------*/

using Senparc.Weixin.MP.Entities;

namespace Senparc.Weixin.MP.MessageHandlers
{
    public abstract partial class MessageHandler<TC>
    {
#region 接收消息方法

/// <summary>
/// 默认返回消息（当任何OnXX消息没有被重写，都将自动返回此默认消息）
/// </summary>
public abstract IResponseMessageBase DefaultResponseMessage(IRequestMessageBase requestMessage);
//{
//    例如可以这样实现：
//    var responseMessage = this.CreateResponseMessage<ResponseMessageText>();
//    responseMessage.Content = "您发送的消息类型暂未被识别。";
//    return responseMessage;
//}

/// <summary>
/// 预处理文字或事件类型请求。
/// 这个请求是一个比较特殊的请求，通常用于统一处理来自文字或菜单按钮的同一个执行逻辑，
/// 会在执行OnTextRequest或OnEventRequest之前触发，具有以下一些特征：
/// 1、如果返回null，则继续执行OnTextRequest或OnEventRequest
/// 2、如果返回不为null，则终止执行OnTextRequest或OnEventRequest，返回最终ResponseMessage
/// 3、如果是事件，则会将RequestMessageEvent自动转为RequestMessageText类型，其中RequestMessageText.Content就是RequestMessageEvent.EventKey
/// </summary>
public virtual IResponseMessageBase OnTextOrEventRequest(RequestMessageText requestMessage)
{
    return null;
}

/// <summary>
/// 文字类型请求
/// </summary>
public virtual IResponseMessageBase OnTextRequest(RequestMessageText requestMessage)
{
    return DefaultResponseMessage(requestMessage);
}

/// <summary>
/// 位置类型请求
/// </summary>
public virtual IResponseMessageBase OnLocationRequest(RequestMessageLocation requestMessage)
{
    return DefaultResponseMessage(requestMessage);
}

/// <summary>
/// 图片类型请求
/// </summary>
public virtual IResponseMessageBase OnImageRequest(RequestMessageImage requestMessage)
{
    return DefaultResponseMessage(requestMessage);
}

/// <summary>
/// 语音类型请求
/// </summary>
public virtual IResponseMessageBase OnVoiceRequest(RequestMessageVoice requestMessage)
{
    return DefaultResponseMessage(requestMessage);
}


/// <summary>
/// 视频类型请求
/// </summary>
public virtual IResponseMessageBase OnVideoRequest(RequestMessageVideo requestMessage)
{
    return DefaultResponseMessage(requestMessage);
}


/// <summary>
/// 链接消息类型请求
/// </summary>
public virtual IResponseMessageBase OnLinkRequest(RequestMessageLink requestMessage)
{
    return DefaultResponseMessage(requestMessage);
}

/// <summary>
/// 小视频类型请求
/// </summary>
public virtual IResponseMessageBase OnShortVideoRequest(RequestMessageShortVideo requestMessage)
{
    return DefaultResponseMessage(requestMessage);
}

#endregion

    }
}
